import { router } from "../router";
import { AppRouteModule } from "/@ts/router/types";
export const useGoPage = (path: string) => {
  router.push(path);
};
/**
 * 路由结构
 * routes 路由数组       二级路由
 */
export const useRouteStructure = (
  routes: AppRouteModule[],
): AppRouteModule[] => {
  let formatRouteMenuList: AppRouteModule[] = [];
  for (let index = 0; index < routes.length; index++) {
    const element: AppRouteModule = routes[index];
    if (element.children && element.children.length > 0) {
      formatRouteMenuList = formatRouteMenuList.concat(
        useRouteStructure(element.children),
      );
    } else {
      formatRouteMenuList.push(element);
    }
  }
  return formatRouteMenuList;
};
// /**
//  * 加载组件
//  * @param view 组件路径
//  * @returns
//  */
// export const loadView = (view:string) => {
//     if (process.env.NODE_ENV === 'development') {
//       return (resolve:any) => require([`@/views/${view}`], resolve)
//     } else {
//       // 使用 import 实现生产环境的路由懒加载
//       return () => import(`@/views/${view}`)
//     }
//   }
